<?php
// src/Acme/StoreBundle/Entity/Product.php
namespace Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User {
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    
    /**
     * @ORM\Column(type="string", length=256)
     */
    protected $acct;
    
    /**
     * @ORM\Column(type="string", length=32)
     */
    protected $salt;
    
    /**
     * @ORM\Column(type="string", length=32)
     */
    protected $pass;
    
    /**
     * @ORM\Column(type="string", length=256)
     */
    protected $email;
    
    /**
     * @ORM\Column(type="date")
     */
    protected $created;
    
    /**
     * @ORM\Column(type="string", length=32)
     */
    protected $resetToken;
    
    /**
     * @ORM\Column(type="datetime")
     */
    protected $resetExpire;
    
    /**
     * @ORM\OneToMany(targetEntity="Purchase", mappedBy="owner")
     **/
    protected $purchases;

    public function __construct()
    {
        $this->salt = substr( "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", mt_rand(0, 50) , 1) .substr( md5( time() ), 1);
        $this->email = '';
        $this->created = new \DateTime('now');
        $this->resetToken = '';
        $this->resetExpire = new \DateTime('now');
        $this->purchases = new ArrayCollection();
    }
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set acct
     *
     * @param string $acct
     * @return User
     */
    public function setAcct($acct)
    {
        $this->acct = $acct;
    
        return $this;
    }

    /**
     * Get acct
     *
     * @return string 
     */
    public function getAcct()
    {
        return $this->acct;
    }

    /**
     * Set salt
     *
     * @param string $salt
     * @return User
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;
    
        return $this;
    }

    /**
     * Get salt
     *
     * @return string 
     */
    public function getSalt()
    {
        return $this->salt;
    }

    /**
     * Set pass
     *
     * @param string $pass
     * @return User
     */
    public function setPass($pass)
    {
        $this->pass = $pass;
    
        return $this;
    }

    /**
     * Get pass
     *
     * @return string 
     */
    public function getPass()
    {
        return $this->pass;
    }

    /**
     * Add purchases
     *
     * @param \Entity\Purchase $purchases
     * @return User
     */
    public function addPurchase(\Entity\Purchase $purchases)
    {
        $this->purchases[] = $purchases;
    
        return $this;
    }

    /**
     * Remove purchases
     *
     * @param \Entity\Purchase $purchases
     */
    public function removePurchase(\Entity\Purchase $purchases)
    {
        $this->purchases->removeElement($purchases);
    }

    /**
     * Get purchases
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getPurchases()
    {
        return $this->purchases;
    }

    /**
     * Set created
     *
     * @param \DateTime $created
     * @return User
     */
    public function setCreated($created)
    {
        $this->created = $created;
    
        return $this;
    }

    /**
     * Get created
     *
     * @return \DateTime 
     */
    public function getCreated()
    {
        return $this->created;
    }

    /**
     * Set email
     *
     * @param string $email
     * @return User
     */
    public function setEmail($email)
    {
        $this->email = $email;
    
        return $this;
    }

    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set reset_token
     *
     * @param string $resetToken
     * @return User
     */
    public function setResetToken($resetToken)
    {
        $this->reset_token = $resetToken;
    
        return $this;
    }

    /**
     * Get reset_token
     *
     * @return string 
     */
    public function getResetToken()
    {
        return $this->reset_token;
    }

    /**
     * Set reset_expire
     *
     * @param \DateTime $resetExpire
     * @return User
     */
    public function setResetExpire($resetExpire)
    {
        $this->reset_expire = $resetExpire;
    
        return $this;
    }

    /**
     * Get reset_expire
     *
     * @return \DateTime 
     */
    public function getResetExpire()
    {
        return $this->reset_expire;
    }
}